/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pos.Driving.Dashboard.Image;

import pos.Driving.Dashboard.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import pos.utils.Invokeable;

/**
 *
 * @author Administrator
 */
public class Dashboard extends BranchGroup implements Invokeable, IDashboard{
    private SpeedMeter meter;
    private ControlPane cp;
    private ControlPane3D cp3D;
    private StationInfo stationInfo;
    
    public Dashboard() {
        this.setCapability(ALLOW_DETACH);
        Transform3D t3d=new Transform3D(), t3dt=new Transform3D();
        t3d.set(new Vector3f(-1.4f,-0.8f,-5f));
        t3dt.set(new Vector3f(-0.7f,-2.25f,-12f));
        meter=new SpeedMeter(t3d,t3dt);
        this.addChild(meter);
        
        t3d.set(new Vector3f(1.45f,-0.65f,-5f));
        cp=new ControlPane(t3d);
        this.addChild(cp);
        
        t3d.set(new Vector3f(-0.8f,-2.4f,-2.5f));
        cp3D=new ControlPane3D(t3d);
       // ControlCenter.dashBoardRoot.addChild(cp3D);
        
        t3d.set(new Vector3f(-1.35f,1.2f,-5f));
        stationInfo=new StationInfo(t3d,600,180d,"");
        this.addChild(stationInfo);
    }
    
    @Override
    public void setDest(double currentD){
        stationInfo.setDest(currentD);
    }
    
    @Override
    public void setPower(double power){
        cp.setPow(power);
        cp3D.setPow(power);
    }
    
    @Override
     public void setDestRef(double destRef) {
        stationInfo.setDestRef(destRef);
    }

    @Override
    public void setStationName(String stationName) {
        stationInfo.setStationName(stationName);
       // System.out.println(stationName);
    }

    @Override
    public void setTimeRef(double timeRef) {
        stationInfo.setTimeRef(timeRef);
    }
    
    @Override
    public void setCurrentSpeed(SpeedDesc Speed) {
        meter.setCurrentSpeed(Speed);
    }
    
    @Override
    public void setControlMode(String str){
        meter.setNextSignture(str);
    }
    @Override
    public void setTime(double time) {
        stationInfo.setTime(time);
    }
    @Override
    public void setCPVisualType(int type){
        cp3D.setVisualType(type);
        cp.setVisualType(type);
        if (type == 3)
            meter.setMode(true);
        else
            meter.setMode(false);
    }
    @Override
    public void invoke(double Step) {
        meter.invoke(Step);
        cp.invoke(Step);
        cp3D.invoke(Step);
       // stationInfo.invoke(Step);
    }
    
   public double getTimeDiff(){
        return stationInfo.getTimeDiff();
    }
    public double getDestDiff(){
        return stationInfo.getDestDiff();
    }
}
